<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>冻结对象的API</title>
</head>
<body>
    <script>
        // 'use strict' 
        let hd = {name:"后盾人",age:18};
        console.log(JSON.stringify(Object.getOwnPropertyDescriptors(hd),null,2));

        // 冻结对象（这个对象不能修改已有属性，添加属性，删除属性，也不能重新定义特征，比封闭状态更严格）,严格模式下报错
        // Object.freeze(hd);
        // console.log(JSON.stringify(Object.getOwnPropertyDescriptors(hd),null,2));

        // hd.name = 'xiasnn';
        // hd.size = 'big';
        // delete hd.age;
        // console.log(hd);


        // Object.freeze(hd);
        // 判断对象是否被冻结
        if(!Object.isFrozen(hd)){
            hd.name = 'xiasnn';
            hd.size = 'big';
            delete hd.age;
        }
        console.log(hd);
    </script>
</body>
</html>